<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <button @click="changeAge">修改年龄</button>
        <son1 :info1="age"></son1>
    </div>
    <template id="son1">
        <div>
            <p>age: {{info1}}</p>
            <button @click="change">美容针</button>
        </div>
    </template>
    <script src="../vue.js"></script>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                age: 18,
            },
            methods: {
                changeAge() {
                    this.age ++
                    console.log(this.age);
                }
            },
            components: {
                son1: {
                    template: '#son1',
                    props: ['info1'],
                    data() {
                        return {
                            myAge: this.info1
                        }
                    },
                    methods: {
                        change() {
                            this.myAge --
                        }
                    }
                }
            }
        })
    </script>
</body>
</html>